<template>
	<view class="home">
		<cmd-nav-bar :fixed="true" back left-text="宠物信息" title="" font-color="black" background-color="#ffffff"></cmd-nav-bar>
		<view class="mo_ban"></view>
		<view class="pets_content" v-for="item in dataArr" :style="{backgroundImage:item.backimgs}">
			<view class="pets_inside">
				<image class="pets_head" :src="item.url" mode=""></image>
				<view class="pets_name">{{item.dog_nickname}}</view>
				<view class="pets_text_">
					<text>{{item.dog_variety}}</text>|<text>{{dogage(item.dog_age)}}岁</text>|<text>{{item.dog_sex}}</text>
				</view>
				<view class="pets_Label">
						<text v-for="ba in item.bag" :class="ba.ClSuccess" @click="toimg(ba)"><span @click="showModal" data-target="Image">{{ba.name}}</span></text>
				</view>

			</view>
		</view>

		<view class="cu-modal" :class="modalName=='Image'?'show':''">
			<view class="cu-dialog">
				<div class="img_box">
					<img :src="imgurlz" alt="">
				</div>
				<view class="cu-bar bg-white">
					<view class="action margin-0 flex-sub  solid-left" @tap="hideModal">返回</view>
				</view>
			</view>
		</view>


		<div class="title_con">
			<div class="text_box" :class="{'selection':flag}" @click="toother(true)">免疫记录</div>
			<div class="text_box" :class="{'selection':!flag}" @click="toother(false)">就诊记录</div>
		</div>

		<view class="process_content" v-for="item in dataval">
			<view class="header_bottom">
				<view class="process_header">
					<text class="text_">{{item.title}}单号:</text>
					<text class="number_">{{item.number}}</text>
				</view>
			</view>
			<view class="process_body">
				<view class="pro_cen">
					<view class="pro_key">
						名称
					</view>
					<view class="pro_name">
						{{item.name}}
					</view>
				</view>
				<view class="pro_cen">
					<view class="pro_key">
						时间
					</view>
					<view class="pro_name">
						{{item.time}}
					</view>
				</view>
				<view class="pro_cen">
					<view class="pro_key">
						医院
					</view>
					<view class="pro_name">
						{{item.hospitla}}
					</view>
				</view>
				<view class="pro_cen">
					<view class="pro_key">
						费用
					</view>
					<view class="pro_name">
						{{item.money}}元
					</view>
				</view>
				<!-- <uni-steps class="home_header" :data="header_top" :active="item.active_">
				</uni-steps> -->
			</view>
		</view>
	</view>
</template>
<script>
	import cmdNavBar from "@/components/cmd-nav-bar/cmd-nav-bar.vue"
	import uniSteps from "@/components/uni-steps/uni-steps.vue"

	import dog_7 from '@/static/dog/7.jpg'
	import dog_6 from '@/static/dog/6.jpg'
	import dog_5 from '@/static/dog/5.jpg'
	
	import dianzi from '@/pages/myimg/dianzi.png'
	import mianyi from '@/pages/myimg/mianyi.png'
	import qrco from '@/pages/myimg/qrco.png'
	export default {
		props: {},
		components: {
			cmdNavBar,
			uniSteps
		},
		data() {
			return {
				flag: true,
				modalName: null,

				ClSuccess: 'clno', // 'clok''clno'
				backimg: 'url(' + dog_7 + ')',
				dataval: [],
				imgarray: dog_5,
				imgurlz: dianzi,
				imgarr:[dianzi,mianyi,qrco],
				learray: [
// 					{
// 					'title': '免疫',
// 					'number': '1335285462959',
// 					'name': "胖头妹",
// 					'time': '2018-4-23',
// 					'hospitla': '绵阳吉祥宠物医院',
// 					'money': 255
// 				}, {
// 					'title': '免疫',
// 
// 					'number': '36595982599',
// 					'name': "胖头妹",
// 					'time': '2018-4-23',
// 					'hospitla': '绵阳吉祥宠物医院',
// 					'money': 245
// 				}],
// 				riarray: [{
// 					'title': '就诊',
// 					'number': '1335285462959',
// 					'name': "胖头妹",
// 					'time': '2018-4-23',
// 					'hospitla': '绵阳吉祥宠物医院',
// 					'money': 255
// 				}, {
// 					'title': '就诊',
// 					'number': '36595982599',
// 					'name': "胖头妹",
// 					'time': '2018-4-23',
// 					'hospitla': '绵阳吉祥宠物医院',
// 					'money': 245
// 				},
				],
				header_top: [{
					title: "提交申请"
				}, {
					title: "育苗接种"
				}, {
					title: "芯片注射"
				}, {
					title: "受理完成"
				}],
				dataArr: [],
				// 'bag': [{
				// 	'name': '电子犬证',
				// 	'ClSuccess': 'clok',
				// 	'imgur': 1
				// }, {
				// 	'name': '免疫证',
				// 	'ClSuccess': 'clno',
				// 	'imgur': 2
				// }, {
				// 	'name': '二维码',
				// 	'ClSuccess': 'qrcode',
				// 	'imgur': 3
				// }],
			}
		},
		methods: {
			dogage(val){ // 获得几岁
				return this.$oneselfFn.GetAge(val)
			},
			toother(n) {
				this.flag = n
				if (n) {
					this.dataval = this.learray
				} else {
					this.dataval = this.riarray
				}
			},
			toimg(item) {
				console.log(item.imgur)
				 switch(item.imgur){
					 case 1:
					 this.imgurlz = this.imgarr[0];
					 break;
					 case 2:
					 this.imgurlz = this.imgarr[1];
					 break;
					 case 3:
					 this.imgurlz = this.imgarr[2];
					 break;
					 default:
					 this.imgurlz = this.imgarr[0];
					 
				 }
			},
			showModal(e) {
				this.modalName = e.currentTarget.dataset.target
			},
			hideModal(e) {
				this.modalName = null
			},
		},
		watch: {},

		onReachBottom() { //页面上拉触底事件的处理函数

		},
		onPullDownRefresh() { //监听用户下拉动作，一般用于下拉刷新
			//需要在 pages.json 里，找到的当前页面的pages节点，并在 style 选项中开启 enablePullDownRefresh
			//uni.startPullDownRefresh(); 开启
			// uni.stopPullDownRefresh(); 关闭
		},
		onUnload() { //监听页面卸载

		},
		onHide() { //监听页面隐藏

		},
		onLoad(option) { // 替代 created 监听页面加载，其参数为上个页面传递的数据，参数类型为Object（用于页面传参），参考示例
if(option.val){
	console.log(JSON.parse(option.val))
	this.dataArr.push(JSON.parse(option.val))
}
		},
		onReady() { //替代 mounted 监听页面初次渲染完成
			this.dataval = this.learray
		},

		onShow() { //监听页面显示
			//生命周期
		}
	}
</script>
<style lang="scss" scoped>
	.home {
		width: 100%;
		height: 100%;
	}

	.img_box {
		width: 90%;
		height: 120vw;
		margin: auto;
	}

	button .cu-tag {
		position: absolute;
		top: 8upx;
		right: 8upx;
	}

	img {
		width: 100%;
		height: 100%;
	}

	.heightimg {
	}

	.pets_content {
		width: 90%;
		height: 300upx;
		border-radius: 16upx;
		border: 1px solid #F4F5F6;
		margin: 40upx auto auto auto;
		background-size:100% 100%;
		// 		 -webkit-filter: blur(1px); /* Chrome, Safari, Opera */
		//     filter: blur(1px);

		.pets_inside {
			width: 80%;
			height: 200upx;
			border-radius: 16upx;
			margin: 40upx auto auto auto;
			// border: 1px solid #181818;
			background: #ffffffe8;

			.pets_head {
				width: 80upx;
				height: 80upx;
				border-radius: 50%;
				position: relative;
				top: -35upx;
				left: 42%;
			}

			.pets_name {
				width: 100%;
				height: 40upx;
				line-height: 40upx;
				text-align: center;
				font-weight: bolder;
				position: relative;
				top: -19px;
			}

			.pets_text_ {
				width: 70%;
				height: 40upx;
				margin: auto;
				display: flex;
				position: relative;
				top: -19px;
				font-size: 11px;
				color: #737373;

				text {
					width: 33%;
					height: 100%;
					text-align: center;
				}
			}

			.pets_Label {
				position: relative;
				top: -12px;
				width: 70%;
				height: 40upx;
				margin: auto;
				display: flex;

				.clok {
					width: 30%;
					height: 100%;
					border-radius: 10upx;
					background: #40c8ff;
					text-align: center;
					line-height: 40upx;
					font-size: 11px;
					color: #ffffff;
					margin-left: 3%;
				}

				.clno {
					width: 30%;
					height: 100%;
					border-radius: 10upx;
					background: darkgreen;
					text-align: center;
					line-height: 40upx;
					font-size: 11px;
					color: white;
					margin-left: 3%;
				}

				.qrcode {
					width: 30%;
					height: 100%;
					border-radius: 10upx;
					background: coral;
					text-align: center;
					line-height: 40upx;
					font-size: 11px;
					color: white;
					margin-left: 3%;
				}
			}
		}
	}

	.mo_ban {
		width: 100%;
		height: 92upx;
	}

	.text_box {
		width: 50%;
		height: 100%;
		float: left;
		text-align: center;
		line-height: 10vw;
	}

	.process_content {
		width: 90%;
		height: 350upx;
		margin: 30upx auto auto auto;
		background: white;
		border-radius: 15upx;

		.header_bottom {
			width: 100%;
			height: 50upx;
			border-bottom: 1px solid #F4F5F6;

			.process_header {
				display: flex;
				width: 90%;
				margin: auto;

				text {
					height: 50upx;
					line-height: 50upx;
				}

				.text_ {
					width: 30%;
					border-left: 3px solid red;
					text-indent: 15upx;
				}

				.number_ {
					// width: 69%;
				}
			}
		}

		.process_body {
			width: 100%;
			height: 300upx;
			border-bottom: 1px solid #F4F5F6;

			.pro_cen {
				display: flex;
				width: 90%;
				height: 70upx;
				margin: auto;

				view {
					height: 70upx;
					line-height: 70upx;
					color: #464c5b;
				}

				.pro_key {
					width: 40%;
				}

				.pro_name {
					width: 60%;
					text-align: right;
				}
			}
		}

		.home_header {
			width: 90%;
			margin: auto;
		}
	}

	.title_con {
		width: 90%;
		height: 10vw;
		background: white;
		margin-top: 10px;
		margin-left: 5%;
	}

	.selection {
		color: orangered;
		font-weight: bold;
		text-decoration: underline;
	}
</style>
